package com.pengheng.controller;

import com.pengheng.server.ChannelHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SendMsgController {

    /**
     * 给所有的客户端发送消息
     */
    @RequestMapping("sendMsg")
    public void sendMsg() {
        ChannelHandler.writeAndFlush("Hello Client");
    }

    /**
     * 给单个客户端发送消息
     */
    @RequestMapping("sendMsgToClient")
    public void sendMsgToClient(String address) {
        ChannelHandler.writeAndFlush(address, "Hello world");

    }
}
